package internal

import (
	"context"
	"encoding/json"
	"server/app/g1/internal/model"
	"server/libs/db"
)

func AwardList_Cache() {
	var AwardList []model.HomeAwardRecord
	err := db.Mysql().Debug().Model(&model.HomeAwardRecord{}).
		Where("award_state_dict =? ", OPEN_AWARD_FINISH).
		Order("created_at desc,id desc").
		Limit(100).
		Find(&AwardList).
		Error
	if err != nil {
		return
	}
	data, err := json.Marshal(AwardList)
	if err != nil {
		return
	}
	ctx := context.Background()
	db.Redis().Set(ctx, "AwardRecordList", string(data), ZERO_VALUE)
}
